package com.github.ghsea.scheduler.repository;

import com.github.ghsea.scheduler.entity.AliveTaskStatistics;
import com.github.ghsea.scheduler.entity.TaskEntity;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * @author guhai
 * @since 2021/6/19 9:24
 */
@Mapper
@Repository
public interface TaskRepository {

    List<TaskEntity> findAliveTasks(@Param("serverId") String serverId,
                                    @Param("startId")long startId,
                                    @Param("limit")int limit);

    AliveTaskStatistics aliveTaskStatistics(String serverId);

    void insert(TaskEntity task);

    void stopTask(@Param("bizCode")String taskCode,@Param("stopTime") Date stopTime);

    int isTaskAlive(@Param("taskCode")String taskCode);

    void batchUpdateServerByTaskId(List<TaskEntity> tasks);

    TaskEntity queryAliveTaskCode(@Param("taskCode") String taskCode);
}
